package net.dreamlu.qa.model;

import java.util.Date;

import com.jfinal.plugin.activerecord.Model;

/**
 * 答案Model
 * @author lcm
 */
public class Answer extends Model<Answer> {
	private static final long serialVersionUID = 1L;
	public static final Answer dao = new Answer();
	
	// 添加回答的统一处理
	public void addAnswer(Answer answer){
		answer.set("answer_time", new Date()).set("create_time", new Date()).set("update_time", new Date()).save();
	}
	// 更新回答统一处理
	public void updateAnswer(Answer answer){
		answer.set("update_time", new Date()).update();
	}
	
	// 获取该回答的问题
	public Question getQuestion(){
		return Question.dao.findById("user_id");
	}
	
	// 获取该回答的用户
	public User getUser(){
		return User.dao.findById(get("answer_uid"));
	}

}